import { stringify } from 'qs';
import request from '@/utils/request';

const api = '/api/mbl';

export async function query(params) {
  const urlString = `${api}/GetMBLView?${stringify(params)}`;
  return request(urlString);
}

export async function getBillByKey(key) {
  const urlString = `${api}/${key}`;
  return request(urlString);
}

export async function isHasHBL(id) {
  const urlString = `${api}/IsHasHBL?id=${id}`;
  return request(urlString);
}

export async function create(params) {
  return request(`${api}`, {
    method: 'POST',
    body: params,
  });
}

export async function lockBill(params) {
  return request(`${api}/LockBill`, {
    method: 'POST',
    body: params,
  });
}

export async function remove(id) {
  return request(`${api}/${id}`, {
    method: 'DELETE',
  });
}

export async function updateHeaderInfo(params) {
  return request(`${api}/UpdateHeaderInfo`, {
    method: 'POST',
    body: params,
  });
}

export async function updateMBL(params) {
  return request(`${api}/updateMBL`, {
    method: 'POST',
    body: params,
  });
}
// export async function updateBillInfo(params) {
//   return request(`${api}/updateBillInfo`, {
//     method: 'POST',
//     body: params,
//   });
// }

export async function getRelationersByBillId(billId) {
  const urlString = `${api}/GetRelationersByBillId?id=${billId}`;
  return request(urlString);
}


export async function changeFHState(params) {
  return request(`${api}/changeFHState`, {
    method: 'POST',
    body: params,
  });
}